Skip to main content
Feedback

Substring

Updated 10 October 2023

These sample JavaScript or Groovy custom scripting functions map the first three characters of the location code as the region ID and the last five characters as the postal code.

JavaScript example

Inputs- locationCode (Character)
Outputs- regionId
- postalCode

Script

region = locationCode.substring(0, 3);
postalCode = locationCode.substring(locationCode.length-5, locationCode.length);

Groovy example

Inputs- locationCode (Character)
Outputs- regionId
- postalCode

Script

region = locationCode.substring(0, 3);
postalCode = locationCode.substring(locationCode.length()-5, locationCode.length());
On this Page